package ner;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class ExtractionTask {

	private final String inputFilename;
	private String inputContent;
	static List<String> sentences;
	private List<List<String>> baseWords;
	private List<List<String>> POStags;
	private Set<BookCharacter> characters;
	
	
	
	public ExtractionTask(String sourceFilename){
		
		this.inputFilename=sourceFilename;
		
	}

	public String getInputFilename() {
		return inputFilename;
	}

	public void setInputContent(String inputContent) {
		this.inputContent = inputContent;
	}

	public String getInputContent() {
		return inputContent;
	}

	public void setBaseWords(List<List<String>> baseWords) {
		this.baseWords = baseWords;
	}

	public List<List<String>> getBaseWords() {
		return baseWords;
	}

	public void setSentences(List<String> sentences) {
		this.sentences = sentences;
	}

	public List<String> getSentences() {
		return sentences;
	}

	public void setPOStags(List<List<String>> POStags) {
		this.POStags = POStags;
	}

	public List<List<String>> getPOStags() {
		return POStags;
	}

	public void setCharacters(Set<BookCharacter> characters) {
		this.characters = characters;
	}

	public Set<BookCharacter> getCharacters() {
		return characters;
	}
	
	
	
	

	public Map<Integer,List<BookCharacter>> getSentencesWithCharacters(){
		
		Map<Integer,List<BookCharacter>> auxMap=new HashMap<Integer,List<BookCharacter>>();
		List<Integer> remberedNumbers=new ArrayList<Integer>();
		
		for(BookCharacter bch:characters){
			
			for(Integer sentenceNumber:new HashSet<Integer>(bch.getSentencesNumbers())){
				if(auxMap.containsKey(sentenceNumber)){
					
					auxMap.get(sentenceNumber).add(bch);

				}
				else{
					List<BookCharacter> characterList=new ArrayList<BookCharacter>();
					characterList.add(bch);
					auxMap.put(sentenceNumber,characterList);
					remberedNumbers.add(sentenceNumber);
				}
			}
			
			
		}
		
		Map<Integer,List<BookCharacter>> result=new HashMap<Integer,List<BookCharacter>>();
		
		for(Integer sentenceNumber:remberedNumbers){
			result.put(sentenceNumber,auxMap.get(sentenceNumber));
			
		}
		
		return result;
		
		
	}
	
	public void presentResults(){
		
		for(BookCharacter ch:characters){
			//if(ch.getOccurrencesNumber()>5 && ch.getPositiveSentences().size()+ch.getNegativeSentences().size()>0)
			if(ch.getOccurrencesNumber()>20)	
				System.out.println(ch);
		}
		
	}
	

	
	
}
